package project.euler.honk.problem.to50;

public final class Problem12 {

	private static int current = 0;
	private static int addMe = 1;

	private static int createNext() {
		current += addMe;
		addMe++;
		return current;
	}

	private static int numberOfFactors() {
		int count = 1;
		int max = ((int) Math.sqrt(current)) + 1;
		for (int i = 2; i <= max; i++)
			if (current % i == 0)
				count += 2;
		return count;
	}
	
	public static int solve() {
		int count = 0;
		int success = 0;
		while (count < 500) {
			success = createNext();
			count = numberOfFactors();
		}
		return success;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		int result = solve();
		long end = System.currentTimeMillis();
		System.out.println("Result: " + result + " Time: " + (end - start));
	}

}
